package com.saver.view.office.config;

import com.saver.office.servlet.OfficeServlet;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class ServletConfig {

    @Autowired
    private ServerConfig serverConfig;

    @Bean
    public ServletRegistrationBean office() {
        OfficeServlet officeServlet = new OfficeServlet();

        ServletRegistrationBean servletRegistrationBean = new ServletRegistrationBean(
                officeServlet, "/office/*");
        servletRegistrationBean.addInitParameter("rootPath", serverConfig.getFile());
        return servletRegistrationBean;
    }
}
